package com.wzcl.app.model.vo;

import com.wzcl.app.dao.model.Delivery;
import com.wzcl.app.model.common.WZCL;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@EqualsAndHashCode(callSuper = false)
@Data
public class DeliveryVo extends BaseVo{
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "所属用户手机")
    private String userPhone;

    @ApiModelProperty(value = "订单Id")
    private String orderId;

    @ApiModelProperty(value = "订单编号")
    private String orderNo;

    @ApiModelProperty(value = "收件人姓名")
    private String name;

    @ApiModelProperty(value = "收件人手机")
    private String phone;

    @ApiModelProperty(value = "详细地址")
    private List<String> path;

    @ApiModelProperty(value = "详细地址")
    private String pathInfo;

    @ApiModelProperty(value = "快递单号")
    private String deliveryNo;

    @ApiModelProperty(value = "快递公司")
    private String deliveryCompany;

    @ApiModelProperty(value = "快递状态")
    private Integer deliveryState;
    private String deliveryStateStr;

    @ApiModelProperty(value = "货物描述")
    private String description;

    @ApiModelProperty(value = "状态")
    private Integer state;
    private String stateStr;

    private DeliveryVo() {
    }

    public static DeliveryVo create(Delivery delivery){
        DeliveryVo deliveryVo = new DeliveryVo();
        BeanUtils.copyProperties(delivery,deliveryVo,"path");
        deliveryVo.path = Arrays.asList(delivery.getPath().split(","));
        deliveryVo.translationValueStr();
        return deliveryVo;
    }

    @Override
    public void translationValueStr() {
        Map<String, Map<Integer, String>> map = getTranslationMap();
        this.deliveryStateStr = map.get(WZCL.GROUP_NAME.DELIVERY_STATE).get(this.deliveryState);
        this.stateStr = map.get(WZCL.GROUP_NAME.STATE).get(this.state);
    }

    @Override
    public void processResources() {

    }
}
